From f7dc8a233fa77cf098714cf50e9ae3fba2204a88 Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Fri, 26 May 2006 22:39:58 +0000 Subject: [PATCH] Add Topo 6 stuff to an1 format, adjust tests for new information git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2121 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/an1.c | 173 ++++++++++++++++-- gpsbabel/reference/an1-an1.ref | Bin 2958 -> 3556 bytes gpsbabel/reference/an1-out.ref | Bin 280 -> 326 bytes .../xmldoc/formats/options/an1-wpt_type.xml | 12 +- 4 files changed, 169 insertions(+), 16 deletions(-) diff --git a/gpsbabel/an1.c b/gpsbabel/an1.c index d7cb074a7..8d603469b 100644 --- a/gpsbabel/an1.c +++ b/gpsbabel/an1.c @@ -58,9 +58,9 @@ roadchange *roadchanges = NULL; static arglist_t an1_args[] = { - {"type", &output_type, "Type of .an1 file (see README)", + {"type", &output_type, "Type of .an1 file", "", ARGTYPE_STRING, ARG_NOMINMAX }, - {"road", &road_changes, "Road type changes (see README)", + {"road", &road_changes, "Road type changes", "", ARGTYPE_STRING, ARG_NOMINMAX }, {"nogc", &nogc, "Do not add geocache data to description", NULL, ARGTYPE_BOOL, ARG_NOMINMAX }, @@ -71,7 +71,7 @@ arglist_t an1_args[] = { {"zoom", &opt_zoom, "Zoom level to reduce points", NULL, ARGTYPE_INT, ARG_NOMINMAX }, {"wpt_type", &opt_wpt_type, - "Waypoint type (marker,text,mapnote,circle)", + "Waypoint type", "", ARGTYPE_STRING, ARG_NOMINMAX }, {"radius", &opt_radius, "Radius for circles", NULL, ARGTYPE_STRING, ARG_NOMINMAX }, @@ -258,6 +258,14 @@ typedef struct { long fillcolor; long unk6; long fillflags; + + /* Added in SA2006/Topo 6.0 */ + short unk6_1; + char *url; + char *comment; + long creation_time; + long modification_time; + char *image_name; } an1_waypoint_record; typedef struct { @@ -296,6 +304,9 @@ void Destroy_AN1_Waypoint( void *vwpt ) { an1_waypoint_record *wpt = (an1_waypoint_record *)vwpt; xfree( wpt->name ); xfree( wpt->fontname ); + xfree( wpt->url ); + xfree( wpt->comment ); + xfree( wpt->image_name ); xfree( vwpt ); } @@ -305,6 +316,9 @@ void Copy_AN1_Waypoint( void **vdwpt, void *vwpt ) { memcpy( dwpt, wpt, sizeof( an1_waypoint_record )); dwpt->name = xstrdup( wpt->name ); dwpt->fontname = xstrdup( wpt->fontname ); + dwpt->url = xstrdup( wpt->url ); + dwpt->comment = xstrdup( wpt->comment ); + dwpt->image_name = xstrdup( wpt->image_name ); *vdwpt = (void *)dwpt; } @@ -393,8 +407,53 @@ static void Read_AN1_Waypoint( FILE *f, an1_waypoint_record *wpt ) { wpt->radius = ReadDouble( f ); len = ReadShort( f ); wpt->name = ReadString( f, len ); - len = ReadShort( f ); - wpt->fontname = ReadString( f, len ); + + if ( len != strlen(wpt->name)) { + /* This happens in 06/6.0 files that put extra data in the + * name record for backward compatibility's sake */ + char *ofs = wpt->name + strlen( wpt->name ) + 1; + wpt->unk6_1 = le_read16( ofs ); + ofs += 2; + + len = le_read16( ofs ); + ofs += 2; + + if ( len ) { + wpt->url = xcalloc( len+1, 1 ); + memcpy( wpt->url, ofs, len ); + ofs += len; + } + + len = le_read16( ofs ); + ofs += 2; + + if ( len ) { + wpt->comment = xcalloc( len+1, 1 ); + memcpy( wpt->comment, ofs, len ); + ofs += len; + } + + /* these are quadwords, presumably for year-2038 compat. */ + wpt->creation_time = le_read32( ofs ); + ofs += 8; + + wpt->modification_time = le_read32( ofs ); + ofs += 8; + } + + if ( wpt->type == 0x12 ) { + /* 'image' type */ + ReadShort( f ); /* length of font + filename */ + len = ReadShort( f ); + wpt->fontname = ReadString( f, len ); + len = ReadShort( f ); + wpt->image_name = ReadString( f, len ); + } + else { + len = ReadShort( f ); + wpt->fontname = ReadString( f, len ); + wpt->image_name = NULL; + } ReadGuid( f, &wpt->guid ); wpt->fontcolor = ReadLong( f ); wpt->fontstyle = ReadLong( f ); @@ -425,12 +484,64 @@ static void Write_AN1_Waypoint( FILE *f, an1_waypoint_record *wpt ) { WriteChar( f, wpt->visible_zoom ); WriteShort( f, wpt->unk5 ); WriteDouble( f, wpt->radius ); - len = strlen( wpt->name ); + + len = strlen( wpt->name ) + 1 + 2 + 2 + + (wpt->url ? strlen( wpt->url ) : 0) + 2 + + (wpt->comment ? strlen( wpt->comment ) : 0) + 8 + 8; WriteShort( f, len ); WriteString( f, wpt->name ); - len = strlen( wpt->fontname ); - WriteShort( f, len ); - WriteString( f, wpt->fontname ); + WriteChar( f, 0 ); /* name string terminator */ + + WriteShort( f, wpt->unk6_1 ); + + if ( wpt->url ) { + WriteShort( f, strlen(wpt->url)); + WriteString( f, wpt->url ); + } + else { + WriteShort( f, 0 ); + } + + if ( wpt->comment ) { + WriteShort( f, strlen(wpt->comment)); + WriteString( f, wpt->comment ); + } + else { + WriteShort( f, 0 ); + } + + WriteLong( f, wpt->creation_time ); + WriteLong( f, 0 ); + + WriteLong( f, wpt->modification_time ); + WriteLong( f, 0 ); + + if ( wpt->type == 0x12 ) { /* image */ + len = 2 + (wpt->fontname ? strlen( wpt->fontname ) : 0 ) + + 2 + (wpt->image_name ? strlen( wpt->image_name ) : 0 ); + WriteShort( f, len ); + if ( wpt->fontname ) { + len = strlen( wpt->fontname ); + WriteShort( f, len ); + WriteString( f, wpt->fontname ); + } + else { + WriteShort( f, 0 ); + } + if ( wpt->image_name ) { + len = strlen( wpt->image_name ); + WriteShort( f, len ); + WriteString( f, wpt->image_name ); + } + else { + WriteShort( f, 0 ); + } + } + else { + len = strlen( wpt->fontname ); + WriteShort( f, len ); + WriteString( f, wpt->fontname ); + } WriteGuid( f, &wpt->guid ); WriteLong( f, wpt->fontcolor ); WriteLong( f, wpt->fontstyle ); @@ -603,17 +714,27 @@ static void Read_AN1_Waypoints( FILE *f ) { Read_AN1_Waypoint( f, rec ); wpt_tmp = waypt_new(); + if ( rec->creation_time ) { + wpt_tmp->creation_time = rec->creation_time; + } wpt_tmp->longitude = -DecodeOrd( rec->lon ); wpt_tmp->latitude = DecodeOrd( rec->lat ); + wpt_tmp->notes = xstrdup( rec->comment ); wpt_tmp->description = xstrdup( rec->name ); - if ( NULL != (url=strstr(wpt_tmp->description, "{URL="))) { + if ( rec->url ) { + wpt_tmp->url = xstrdup( rec->url ); + } + else if ( NULL != (url=strstr(wpt_tmp->description, "{URL="))) { *url = '\0'; url += 5; url[strlen(url)-1] = '\0'; wpt_tmp->url = xstrdup( url ); } - if (FindIconByGuid(&rec->guid, &icon)) { + if ( rec->image_name ) { + wpt_tmp->icon_descr = xstrdup( rec->image_name ); + } + else if (FindIconByGuid(&rec->guid, &icon)) { wpt_tmp->icon_descr = icon; } @@ -656,6 +777,7 @@ Write_One_AN1_Waypoint( const waypoint *wpt ) FindIconByName( opt_symbol, &rec->guid ); rec->fontsize = 10; rec->visible_zoom = opt_zoom?opt_zoom_num:10; + rec->unk6_1 = 1; } rec->name = xstrdup( wpt->description ); @@ -675,13 +797,30 @@ Write_One_AN1_Waypoint( const waypoint *wpt ) sprintf( extra, "{URL=%s}", wpt->url ); rec->name = xstrappend( rec->name, extra ); xfree( extra ); + rec->url = xstrdup( wpt->url ); } - + + if ( wpt->notes ) { + if ( rec->comment ) { + xfree( rec->comment ); + } + rec->comment = xstrdup( wpt->notes ); + } + + + rec->creation_time = rec->modification_time = wpt->creation_time; rec->lat = EncodeOrd( wpt->latitude ); rec->lon = EncodeOrd( -wpt->longitude ); rec->serial = serial++; - if ( wpt->icon_descr ) { + if ( wpt_type_num == 0x12 ) { /* image */ + if ( strstr( wpt->icon_descr, ":\\" )) { + rec->image_name = xstrdup( wpt->icon_descr ); + rec->height = -244; + rec->width = -1; + } + } + if ( !rec->image_name && wpt->icon_descr ) { FindIconByName( (char *)(void *)wpt->icon_descr, &rec->guid ); } @@ -903,6 +1042,9 @@ Init_Wpt_Type( void ) if ( !case_ignore_strcmp( opt_wpt_type, "marker" )) { wpt_type_num = 1; } + else if ( !case_ignore_strcmp( opt_wpt_type, "symbol" )) { + wpt_type_num = 1; /* symbol and marker are synonyms */ + } else if ( !case_ignore_strcmp( opt_wpt_type, "text" )) { wpt_type_num = 4; } @@ -911,10 +1053,13 @@ Init_Wpt_Type( void ) } else if ( !case_ignore_strcmp( opt_wpt_type, "circle" )) { wpt_type_num = 5; + } + else if ( !case_ignore_strcmp( opt_wpt_type, "image" )) { + wpt_type_num = 18; } else { fatal( MYNAME ": wpt_type must be " - "marker, text, mapnote, or circle\n" ); + "symbol, text, mapnote, circle, or image\n" ); } } } diff --git a/gpsbabel/reference/an1-an1.ref b/gpsbabel/reference/an1-an1.ref index 17df313dda5810ea4d6ea27f5263b5f2669eec95..27ccc13efaf6b366b761189b2f637c27f948b1ac 100644 GIT binary patch delta 360 zcmeAZeicx&>MHY$4a*X^Fy%Uf)dk~y_gz)5fj0kc5$^1;nyap8BM-*NXGqTFd zC_EPyWVx*)c~ U1SS`A#Uq8#VoYlb91GbFzS$ zi&zpSOR|EQn^+SjYqEivhu9J(Te5?hm)H{~dvX+l%$@w0BYtuuC&c8>obi)0xe9?s h3QcC_jt9yEl?zQ4=7|SdTnMyOXtFYI{N$Ou-T;0dJBt7S diff --git a/gpsbabel/reference/an1-out.ref b/gpsbabel/reference/an1-out.ref index b7aa356a92054719a65d53217534e60ac3bb8118..fb40144402ecf89bce435a5c230a3749374949c0 100644 GIT binary patch delta 94 zcmbQibc|_&6{G1yYk6@7Mh0wPVpO`WHbZbpeqL%)QGR~5u6t2xWig10Q-d`d6WAmG D`GpQr delta 44 xcmX@cG=ph^6{FllYx#+V>0%-b!6o^5sYylo`PsVeMX8m=AnwFM>&Xs`Yye5L4)g#3 diff --git a/gpsbabel/xmldoc/formats/options/an1-wpt_type.xml b/gpsbabel/xmldoc/formats/options/an1-wpt_type.xml index 8bc01b0a5..dbea684a2 100644 --- a/gpsbabel/xmldoc/formats/options/an1-wpt_type.xml +++ b/gpsbabel/xmldoc/formats/options/an1-wpt_type.xml @@ -1,5 +1,13 @@ This option specifies how to represent point data in the draw file. -Valid waypoint types are "marker", "text", "mapnote", and "circle". -The default is "marker". +Valid waypoint types are "symbol", "text", "mapnote", "circle", and "image". +The default is "symbol". + + +If you specify a waypoint type of "image", you should make sure that the +icon descriptions of your waypoints are the full names, including drive letters +and full path, of image files in a format that works with your DeLorme +product. Note that this means that the .an1 file you generate will not work +on any computer that does not have those images in the same place; this is +part of the design of the an1 format and cannot be avoided. -- 2.30.2